\(\int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx\) [720]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 39, antiderivative size = 48 \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=-\frac {c (A+B \tan (e+f x))^2}{2 a^2 (i A-B) f (1+i \tan (e+f x))^2} \]

[Out]

-1/2*c*(A+B*tan(f*x+e))^2/a^2/(I*A-B)/f/(1+I*tan(f*x+e))^2

Rubi [A] (verified)

Time = 0.08 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.051, Rules used = {3669, 37} \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=-\frac {c (A+B \tan (e+f x))^2}{2 a^2 f (-B+i A) (1+i \tan (e+f x))^2} \]

[In]

Int[((A + B*Tan[e + f*x])*(c - I*c*Tan[e + f*x]))/(a + I*a*Tan[e + f*x])^2,x]

[Out]

-1/2*(c*(A + B*Tan[e + f*x])^2)/(a^2*(I*A - B)*f*(1 + I*Tan[e + f*x])^2)

Rule 37

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_), x_Symbol] :> Simp[(a + b*x)^(m + 1)*((c + d*x)^(n +
1)/((b*c - a*d)*(m + 1))), x] /; FreeQ[{a, b, c, d, m, n}, x] && NeQ[b*c - a*d, 0] && EqQ[m + n + 2, 0] && NeQ
[m, -1]

Rule 3669

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a*(c/f), Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {(a c) \text {Subst}\left (\int \frac {A+B x}{(a+i a x)^3} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {c (A+B \tan (e+f x))^2}{2 a^2 (i A-B) f (1+i \tan (e+f x))^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 1.21 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.25 \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=\frac {c (A \cos (e+f x)+B \sin (e+f x))^2 (i \cos (2 (e+f x))+\sin (2 (e+f x)))}{2 a^2 (A+i B) f} \]

[In]

Integrate[((A + B*Tan[e + f*x])*(c - I*c*Tan[e + f*x]))/(a + I*a*Tan[e + f*x])^2,x]

[Out]

(c*(A*Cos[e + f*x] + B*Sin[e + f*x])^2*(I*Cos[2*(e + f*x)] + Sin[2*(e + f*x)]))/(2*a^2*(A + I*B)*f)

Maple [A] (verified)

Time = 0.15 (sec) , antiderivative size = 46, normalized size of antiderivative = 0.96

method result size
derivativedivides \(\frac {c \left (-\frac {i A -B}{2 \left (-i+\tan \left (f x +e \right )\right )^{2}}-\frac {i B}{-i+\tan \left (f x +e \right )}\right )}{f \,a^{2}}\) \(46\)
default \(\frac {c \left (-\frac {i A -B}{2 \left (-i+\tan \left (f x +e \right )\right )^{2}}-\frac {i B}{-i+\tan \left (f x +e \right )}\right )}{f \,a^{2}}\) \(46\)
risch \(\frac {c \,{\mathrm e}^{-2 i \left (f x +e \right )} B}{4 a^{2} f}+\frac {i c \,{\mathrm e}^{-2 i \left (f x +e \right )} A}{4 a^{2} f}-\frac {c \,{\mathrm e}^{-4 i \left (f x +e \right )} B}{8 a^{2} f}+\frac {i c \,{\mathrm e}^{-4 i \left (f x +e \right )} A}{8 a^{2} f}\) \(80\)
norman \(\frac {\frac {c A \tan \left (f x +e \right )}{a f}+\frac {i c A +c B}{2 a f}+\frac {\left (-i c A +3 c B \right ) \tan \left (f x +e \right )^{2}}{2 a f}-\frac {i c B \tan \left (f x +e \right )^{3}}{a f}}{a \left (1+\tan \left (f x +e \right )^{2}\right )^{2}}\) \(95\)

[In]

int((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))/(a+I*a*tan(f*x+e))^2,x,method=_RETURNVERBOSE)

[Out]

1/f*c/a^2*(-1/2*(I*A-B)/(-I+tan(f*x+e))^2-I*B/(-I+tan(f*x+e)))

Fricas [A] (verification not implemented)

none

Time = 0.25 (sec) , antiderivative size = 47, normalized size of antiderivative = 0.98 \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=-\frac {{\left (2 \, {\left (-i \, A - B\right )} c e^{\left (2 i \, f x + 2 i \, e\right )} - {\left (i \, A - B\right )} c\right )} e^{\left (-4 i \, f x - 4 i \, e\right )}}{8 \, a^{2} f} \]

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))/(a+I*a*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

-1/8*(2*(-I*A - B)*c*e^(2*I*f*x + 2*I*e) - (I*A - B)*c)*e^(-4*I*f*x - 4*I*e)/(a^2*f)

Sympy [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 158 vs. \(2 (37) = 74\).

Time = 0.20 (sec) , antiderivative size = 158, normalized size of antiderivative = 3.29 \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=\begin {cases} \frac {\left (\left (4 i A a^{2} c f e^{2 i e} - 4 B a^{2} c f e^{2 i e}\right ) e^{- 4 i f x} + \left (8 i A a^{2} c f e^{4 i e} + 8 B a^{2} c f e^{4 i e}\right ) e^{- 2 i f x}\right ) e^{- 6 i e}}{32 a^{4} f^{2}} & \text {for}\: a^{4} f^{2} e^{6 i e} \neq 0 \\\frac {x \left (A c e^{2 i e} + A c - i B c e^{2 i e} + i B c\right ) e^{- 4 i e}}{2 a^{2}} & \text {otherwise} \end {cases} \]

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))/(a+I*a*tan(f*x+e))**2,x)

[Out]

Piecewise((((4*I*A*a**2*c*f*exp(2*I*e) - 4*B*a**2*c*f*exp(2*I*e))*exp(-4*I*f*x) + (8*I*A*a**2*c*f*exp(4*I*e) +
 8*B*a**2*c*f*exp(4*I*e))*exp(-2*I*f*x))*exp(-6*I*e)/(32*a**4*f**2), Ne(a**4*f**2*exp(6*I*e), 0)), (x*(A*c*exp
(2*I*e) + A*c - I*B*c*exp(2*I*e) + I*B*c)*exp(-4*I*e)/(2*a**2), True))

Maxima [F(-2)]

Exception generated. \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=\text {Exception raised: RuntimeError} \]

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))/(a+I*a*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: expt: undefined: 0 to a negative exponent.

Giac [A] (verification not implemented)

none

Time = 0.47 (sec) , antiderivative size = 79, normalized size of antiderivative = 1.65 \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=-\frac {2 \, {\left (A c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} - i \, A c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - B c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - A c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )\right )}}{a^{2} f {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - i\right )}^{4}} \]

[In]

integrate((A+B*tan(f*x+e))*(c-I*c*tan(f*x+e))/(a+I*a*tan(f*x+e))^2,x, algorithm="giac")

[Out]

-2*(A*c*tan(1/2*f*x + 1/2*e)^3 - I*A*c*tan(1/2*f*x + 1/2*e)^2 - B*c*tan(1/2*f*x + 1/2*e)^2 - A*c*tan(1/2*f*x +
 1/2*e))/(a^2*f*(tan(1/2*f*x + 1/2*e) - I)^4)

Mupad [B] (verification not implemented)

Time = 8.31 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.04 \[ \int \frac {(A+B \tan (e+f x)) (c-i c \tan (e+f x))}{(a+i a \tan (e+f x))^2} \, dx=\frac {\frac {c\,\left (A-B\,1{}\mathrm {i}\right )}{2}+B\,c\,\mathrm {tan}\left (e+f\,x\right )}{a^2\,f\,\left ({\mathrm {tan}\left (e+f\,x\right )}^2\,1{}\mathrm {i}+2\,\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )} \]

[In]

int(((A + B*tan(e + f*x))*(c - c*tan(e + f*x)*1i))/(a + a*tan(e + f*x)*1i)^2,x)

[Out]

((c*(A - B*1i))/2 + B*c*tan(e + f*x))/(a^2*f*(2*tan(e + f*x) + tan(e + f*x)^2*1i - 1i))